import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm"
import { Employee } from "./Employee";

@Entity()
export class Department {

    @PrimaryGeneratedColumn()
    id: number;

    @Column({
        length: 50
    })
    name: string;


    //一对多关系(一)
    @OneToMany(()=>Employee, (employee) => employee.department, //指定外键列在 employee.department 维护。 
    {  
        cascade: true   //更新自动更新,删除自动删除
    }) 
    employees: Employee[];
}
